import type { LoginResult } from '@/types/auth'
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { storage } from '@/stores/persist';
import { isEmpty } from '@/utils/util';


// 定义 Store
export const useImStore = defineStore(
	'im',
	() => {
		const chatUserList = ref<{
			chatId : string;
			chatName : string;
			accId : string;
			nimToken : string;
			checked : boolean;
		}[]>([]);

		function setChatUserList(list : any) {
			chatUserList.value = list;
		}


		const initialized = ref(false);
		const unread = ref(0);

		function setInit(flag = true) {
			initialized.value = flag;
		}

		function setUnread(value : number) {
			unread.value = value
		}

		return {
			chatUserList,
			setChatUserList,
			initialized,
			setInit,
			unread,
			setUnread
		}
	}
)